﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;

namespace GrayParrot.Web.Controls
{
    [Serializable]
    public class Searching : Feature<SearchTypes>
    {
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public ColumnFilters<FiltersComparer<ColumnFilter>> Filters { get; set; }

        public bool ExternalFilters { get; set; }
        public string ExternalFiltersContainerName { get; set; }

        public Searching()
        {
            this.Value = SearchTypes.General;
        }

        public override string ToString()
        {
            string retValue = string.Empty;

            switch (this.Value)
            {
                case SearchTypes.General:
                case SearchTypes.Both:
                    retValue = "\"searching\": true";
                    break;
                case SearchTypes.Individual:
                    retValue = "\"searching\": true";
                    break;
                case SearchTypes.None:
                    retValue = "\"searching\": true";   // hack (  $("input[type=search]").prop("disabled", true); ), altrimenti non funzionano gli eventuali Buttons
                    break;
                default:
                    retValue = "\"searching\": true";
                    break;
            }

            return retValue;
        }
    }
}
